﻿
(function ($) {
    var InitialContainer = function () {
        var R = Raphael("container", "100%", "100%");
        return R;

    };
    //初始化
    var initialPaper = function ($paper) {

        var $contanerwraper = $('<div><div id="designToolbox"></div></div>').appendTo($paper).css('position', 'absolute').css('z-index', '90');
        var $container = $('<div id="container" class="container"></div>').appendTo($paper).css('position', 'absolute').css('z-index', '0'); ;
        var $designToolbox = $("#designToolbox").css('float', 'left').css('width','180px');

        var $switch = $('<div shown="true"></div>').appendTo($designToolbox.parent()).css('float', 'left').css('width', '20px').css('position', 'absolute').attr('z-index', '100').css('height', '600px');

        $switch.css('margin-left', $designToolbox.width() - $switch.width() / 2);
        $switch.addHoverFunctions({
            showIcon: 'always',
            customEvent: function () {
                var width = $designToolbox.width();
                if ($switch.attr('shown') == 'true') {

                    $designToolbox.animate({ marginLeft: -width }, 'slow');
                    $switch.removeAttr('shown');
                    $switch.animate({ marginLeft: -$switch.width() / 2 }, 'slow');
                }
                else {
                    $designToolbox.animate({ marginLeft: 0 }, 'slow');
                    $switch.animate({ marginLeft: width - $switch.width() / 2 }, 'slow');
                    $switch.attr('shown', 'true');
                }
            }
        });

        var R = InitialContainer($paper);
        InitialDesignToolbox($designToolbox, R);
        Initial_activity_edtitor();
    };

    jQuery.fn.initial = function (options) {
        var settings = jQuery.extend({
            itemsPool: 'include', container: 'include'
        }, options);
        var $paper = $(this);
        initialPaper($paper);
        return $paper;
    };
})(jQuery);
